(function (doc, win) {
    var docHTML = doc.documentElement,
    resizeEvtent = 'orientationchange' in window ? 'orientationchange' : 'resize',
    recalc = function () {
        var w = docHTML.clientWidth;
        
        if( w <= 640 && w >= 0){
            docHTML.style.fontSize = 10 * (w / 320) + 'px';
            console.log('1='+docHTML.style.fontSize);
        }else{
            docHTML.style.fontSize = 20 + 'px';
            console.log('2='+docHTML.style.fontSize);
        }
    };

    if (!doc.addEventListener) {return;}
    win.addEventListener(resizeEvtent, recalc, false);
    doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);